package com.elric.mall.common.utils;

import java.util.Objects;

/**
 * 实现功能：Exception异常信息Util
 *
 * @author 作者[Yuxuan.he]
 * @version 1.0.00  2021-09-16 10:44
 */
public class ExceptionMsgUtil {
    /**
     * 导入必填校验提示
     */
    public static String columnRequireErrorReason(int lineNo, Object serialNo, String columnName) {
        StringBuilder builder = new StringBuilder();
        if(Objects.isNull(serialNo)){
            return builder.append("第<").append(lineNo).append(">行<").append(columnName).append(">列为必填项,不能为空!").toString();
        }
        builder.append("序号<").append(serialNo).append(">");
        return builder.append("的<").append(columnName).append(">列为必填项,不能为空!").toString();
    }

    /**
     * 导入字段长度校验提示
     */
    public static String maxLengthErrorReason(int lineNo, Object serialNo, String columnName,int maxLength) {
        StringBuilder builder = new StringBuilder();
        if(Objects.isNull(serialNo)){
            return builder.append("第<").append(lineNo).append(">行<").append(columnName).append(">列对应的值不能超过").append(maxLength).toString();
        }
        builder.append("序号<").append(serialNo).append(">");
        return builder.append("的<").append(columnName).append(">列对应的值不能超过").append(maxLength).toString();
    }
}